<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('租赁设备列表')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="form-group  col-lg-4">
                        <label class="control-label col-sm-4 ">出库单号：</label>
                        <div class="input-group">
                            <input type="text" class="form-control col-sm-4" name="rentNumber" />
                        </div>
                    </div>
                    <div class="form-group  col-lg-4">
                        <label class="control-label col-sm-4 ">器材编号：</label>
                        <div class="input-group">
                            <input type="text" class="form-control col-sm-4" name="deviceSerialNumber" />
                        </div>
                    </div>
                    <div class="form-group  col-lg-4">
                        <label class="control-label col-sm-4 ">计划租赁开始日期时间：</label>
                        <div class="input-daterange input-group">
                            <input type="text" class="input-sm form-control" id="planRentStartTimeStart" name="planRentStartTimeStart" autocomplete="off" placeholder="yyyy-MM-dd"/>
                            <span class="input-group-addon">到</span>
                            <input type="text" class="input-sm form-control" id="planRentStartTimeEnd" name="planRentStartTimeEnd" autocomplete="off" placeholder="yyyy-MM-dd"/>
                        </div>
                    </div>
                    <div class="form-group  col-lg-4">
                        <label class="control-label col-sm-4 ">计划租赁结束日期时间：</label>
                        <div class="input-daterange input-group">
                            <input type="text" class="input-sm form-control" id="planRentEndTimeStart" name="planRentEndTimeStart" autocomplete="off" placeholder="yyyy-MM-dd"/>
                            <span class="input-group-addon">到</span>
                            <input type="text" class="input-sm form-control" id="planRentEndTimeEnd" name="planRentEndTimeEnd" autocomplete="off" placeholder="yyyy-MM-dd"/>
                        </div>
                    </div>
                    <div class="form-group  col-lg-4">
                        <label class="control-label col-sm-4 ">实际租赁开始日期时间：</label>
                        <div class="input-daterange input-group">
                            <input type="text" class="input-sm form-control" id="actualRentStartTimeStart" name="actualRentStartTimeStart" autocomplete="off" placeholder="yyyy-MM-dd"/>
                            <span class="input-group-addon">到</span>
                            <input type="text" class="input-sm form-control" id="actualRentStartTimeEnd" name="actualRentStartTimeEnd" autocomplete="off" placeholder="yyyy-MM-dd"/>
                        </div>
                    </div>
                    <div class="form-group  col-lg-4">
                        <label class="control-label col-sm-4 ">实际租赁结束时间：</label>
                        <div class="input-daterange input-group">
                            <input type="text" class="input-sm form-control" id="actualRentEndTimeStart"  name="actualRentEndTimeStart" autocomplete="off" placeholder="yyyy-MM-dd"/>
                            <span class="input-group-addon">到</span>
                            <input type="text" class="input-sm form-control" id="actualRentEndTimeEnd" name="actualRentEndTimeEnd" autocomplete="off" placeholder="yyyy-MM-dd"/>
                        </div>
                    </div>
                    <div class="form-group  col-lg-4">
                        <label class="control-label col-sm-4 ">计划租赁天数：</label>
                        <div class="input-group">
                            <input type="number" name="planRentSpanStart" class="form-control" autocomplete="off"/>
                            <span class="input-group-addon">到</span>
                            <input type="number" name="planRentSpanEnd"  class="form-control" autocomplete="off"/>
                        </div>
                    </div>
<!--                    <div class="form-group  col-lg-4"></div>-->
                    <div class="form-group  col-lg-4">
                        <label class="control-label col-sm-4 ">实际租赁天数：</label>
                        <div class="input-group input-daterange">
                            <input type="number" name="actualRentSpanStart" class="form-control"  autocomplete="off"/>
                            <span class="input-group-addon">到</span>
                            <input type="number" name="actualRentSpanEnd" class="form-control"  autocomplete="off"/>
                        </div>
                    </div>
                    <div class="form-group  col-lg-4">
                        <label class="control-label col-sm-4 ">备注：</label>
                        <div class="input-group">
                            <input type="text" class="form-control col-sm-4" name="note"/>
                        </div>
                    </div>
                    <div class="form-group  col-lg-4">
                        <label class="control-label col-sm-4 ">状态：</label>
                        <div class="input-group ">
                            <select class="form-control col-sm-4" name="valid" th:with="type=${@dict.getType('sys_rent_valid')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group  col-lg-4">
                        <div class="input-group input-daterange">
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </div>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system:link:edit">
                    <i class="fa fa-edit"></i> 归还设备
                </a>
                <a class="btn btn-primary single disabled" onclick="revokeDevice()" shiro:hasPermission="system:link:edit">
                    <i class="fa fa-edit"></i> 撤销设备
                </a>
<!--                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:link:remove">-->
<!--                    <i class="fa fa-remove"></i> 删除-->
<!--                </a>-->
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:link:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('system:link:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:link:remove')}]];
        var prefix = ctx + "system/link";
        var rentValidDatas = [[${@dict.getType('sys_rent_valid')}]];
        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/gotoReturnDevice/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "【请填写功能名称】",
                columns: [{
                    radio: true
                },
                {
                    field: 'id',
                    title: '主键ID',
                    visible: false
                },
                    {
                        field: 'rentNumber',
                        title: '出库单号'
                    },
                {
                    field: 'typeName',
                    title: '器材类型'
                },
                {
                    field: 'modeName',
                    title: '器材型号'
                },
                {
                    field: 'deviceSerialNumber',
                    title: '器材编号'
                },
                {
                    field: 'planRentStartTime',
                    title: '计划租赁开始日期时间'
                },
                {
                    field: 'actualRentStartTime',
                    title: '实际租赁开始日期时间'
                },
                {
                    field: 'planRentEndTime',
                    title: '计划租赁结束时间'
                },
                {
                    field: 'actualRentEndTime',
                    title: '实际租赁结束时间'
                },
                {
                    field: 'planRentSpan',
                    title: '计划租赁天数'
                },
                {
                    field: 'actualRentSpan',
                    title: '实际租赁天数'
                },
                {
                    field: 'note',
                    title: '备注'
                },
                {
                    field: 'valid',
                    title: '状态',
                    formatter:function (value,row,index){
                        return $.table.selectDictLabel(rentValidDatas, value);
                    }
                }
                // ,{
                //     title: '操作',
                //     align: 'center',
                //     formatter: function(value, row, index) {
                //         var actions = [];
                //         actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                //         // actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                //         return actions.join('');
                //     }
                // }
                ]
            };
            $.table.init(options);
        });

        function revokeDevice(){
            var row = $.table.selectFirstColumns();
            if ($.common.isEmpty(row)) {
                $.modal.alertWarning("请选择一条记录");
                return;
            }else{
                $.modal.confirm("确认要撤销该设备吗?", function() {
                    $.post(ctx + "system/link/revokeDevice", {id: row[0]}, function(result) {
                        $.modal.alert(result.msg);
                    });
                });
            }
        }

        //计划开始租赁时间
        $("#planRentStartTimeStart").datetimepicker({
            format: 'yyyy-mm-dd',
            minView: "month",
            todayBtn:  true,
            autoclose: true,
            // endDate : new Date(),
        }).on('changeDate', function(event) {
            event.preventDefault();
            event.stopPropagation();
            var startTime = event.date;
            $('#planRentStartTimeEnd').datetimepicker('setStartDate', startTime);
        });

        $("#planRentStartTimeEnd").datetimepicker({
            format: 'yyyy-mm-dd',
            minView: "month",
            todayBtn:  true,
            autoclose: true,
            // endDate : new Date(),
        }).on('changeDate', function(event) {
            event.preventDefault();
            event.stopPropagation();
            var endTime = event.date;
            $("#planRentStartTimeStart").datetimepicker('setEndDate', endTime);
        });
        //计划结束租赁时间
        $("#planRentEndTimeStart").datetimepicker({
            format: 'yyyy-mm-dd',
            minView: "month",
            todayBtn:  true,
            autoclose: true,
            // endDate : new Date(),
        }).on('changeDate', function(event) {
            event.preventDefault();
            event.stopPropagation();
            var startTime = event.date;
            $('#planRentEndTimeEnd').datetimepicker('setStartDate', startTime);
        });

        $("#planRentEndTimeEnd").datetimepicker({
            format: 'yyyy-mm-dd',
            minView: "month",
            todayBtn:  true,
            autoclose: true,
            // endDate : new Date(),
        }).on('changeDate', function(event) {
            event.preventDefault();
            event.stopPropagation();
            var endTime = event.date;
            $("#planRentEndTimeStart").datetimepicker('setEndDate', endTime);
        });
        //实际开始租赁时间
        $("#actualRentStartTimeStart").datetimepicker({
            format: 'yyyy-mm-dd',
            minView: "month",
            todayBtn:  true,
            autoclose: true,
            // endDate : new Date(),
        }).on('changeDate', function(event) {
            event.preventDefault();
            event.stopPropagation();
            var startTime = event.date;
            $('#actualRentStartTimeEnd').datetimepicker('setStartDate', startTime);
        });

        $("#actualRentStartTimeEnd").datetimepicker({
            format: 'yyyy-mm-dd',
            minView: "month",
            todayBtn:  true,
            autoclose: true,
            // endDate : new Date(),
        }).on('changeDate', function(event) {
            event.preventDefault();
            event.stopPropagation();
            var endTime = event.date;
            $("#actualRentStartTimeStart").datetimepicker('setEndDate', endTime);
        });
        //实际结束租赁时间
        $("#actualRentEndTimeStart").datetimepicker({
            format: 'yyyy-mm-dd',
            minView: "month",
            todayBtn:  true,
            autoclose: true,
            // endDate : new Date(),
        }).on('changeDate', function(event) {
            event.preventDefault();
            event.stopPropagation();
            var startTime = event.date;
            $('#actualRentEndTimeEnd').datetimepicker('setStartDate', startTime);
        });

        $("#actualRentEndTimeEnd").datetimepicker({
            format: 'yyyy-mm-dd',
            minView: "month",
            todayBtn:  true,
            autoclose: true,
            // endDate : new Date(),
        }).on('changeDate', function(event) {
            event.preventDefault();
            event.stopPropagation();
            var endTime = event.date;
            $("#actualRentEndTimeStart").datetimepicker('setEndDate', endTime);
        });
    </script>
</body>
</html>